﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using Utils;

namespace Model
{
    [Serializable]
    public class Light
    {
        public Point3D Position;
        //might want looking and up vector if lights have models that aren't sphereical
        public Color4 DiffuseColor;
        public Color4 AmbientColor;
        public bool Positional;
        public double Angle;

        public bool Particle;

        public void AddLight(LightName lightName, EnableCap cap)
        {
            GL.Enable(cap);
            var pos = new[] { (float)Position.X, (float)Position.Y, (float)Position.Z, Positional ? 1 : 0 };

            GL.Light(lightName, LightParameter.Position, pos);
            GL.Light(lightName, LightParameter.Ambient, AmbientColor);
            GL.Light(lightName, LightParameter.Diffuse, DiffuseColor);

            if (Angle != 0)
                GL.Light(lightName, LightParameter.SpotCutoff, (float)Angle);

            GL.PointSize(5);
            GL.Begin(BeginMode.Points);
            GL.Vertex3(pos);
            GL.End();                
        }
    }
}
